var a = require("../../../@babel/runtime/helpers/toConsumableArray"), t = getApp();

Page({
    data: {
        language: "",
        member: {},
        deliver_name: "",
        current: 0,
        amount: null,
        dividend: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getData(), this.getInfo();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.package-deliver.frontend.bonus.getDeliverInfo");
        t._getNetWork({
            url: e,
            data: {},
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    amount: e.data.amount,
                    deliver_name: e.data.deliver.deliver_name,
                    member: e.data.deliver.member
                }) : wx.showToast({
                    icon: "none",
                    title: "获取失败",
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getInfo: function() {
        var a = this, e = t.getNetAddresss("plugin.package-deliver.frontend.bonus.getList");
        t._getNetWork({
            url: e,
            data: {},
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    dividend: e.data.list.data,
                    total_page: e.data.list.last_page,
                    isLoadMore: !0,
                    page: e.data.list.current_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var n = this.data.page;
            n += 1, this.setData({
                page: n
            });
            var o = t.getNetAddresss("plugin.package-deliver.frontend.bonus.getList");
            t._getNetWork({
                url: o,
                data: {
                    page: e.data.page
                },
                success: function(t) {
                    var n = t.data;
                    if (1 == n.result) {
                        var o = n.data.list.data, i = [].concat(a(e.data.dividend), a(o));
                        e.setData({
                            dividend: i,
                            total_page: n.data.list.last_page
                        });
                    }
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        }
    }
});